import React, { useEffect, useState } from 'react';
import { Modal, Form, Space } from 'antd';
import FormCondition from '@/components/FormCondition';
import { connect, history } from 'umi';
import { Button, Row, Col } from 'antd';
import aliOssUpload from '@/utils/aliOssUpload';
const UpdateAnswerUser = (props) => {
    const { visible = false, onClose, loading, dispatch, handleCallback, } = props;
    const { show = false, detail = {} } = visible;
    const { id, username, adminName, adminId } = detail;
    const [form] = Form.useForm();
    // 确认提交
    const handleUpAudit = () => {
        form.validateFields().then((values) => {
            dispatch({
                type: 'answering/fakeSaveTeacher',
                payload: {
                    ...values,
                    id
                },
                callback: () => {
                    onClose()
                    handleCallback()
                }
            })
        });
    };
    const formItems = [

        {
            label: '绑定员工',
            name: 'adminId',
            defaultData: {
                username: adminName,
                id: adminId
            },
            type: 'user',
            fieldNames: {
                label: 'username',
                value: 'id'
            },
        },
    ];

    const modalProps = {
        title: '编辑',
        width: 800,
        visible: show,
        maskClosable: true,
        destroyOnClose: true,
        zIndex: 1001,
        confirmLoading: loading,
    };

    return (
        <Modal {...modalProps} onCancel={onClose} onOk={handleUpAudit}>
            <FormCondition formItemLayouts={{
                labelCol: {

                },
                wrapperCol: {

                },
            }} form={form} initialValues={detail} formItems={formItems}></FormCondition>
        </Modal >
    );
};

export default connect(({ order, loading }) => ({
    loading: loading.effects['answering/fakeSaveTeacher'],
}))(UpdateAnswerUser);
;
